// main.cpp
#include "Src/NTWindow.h"
#include "Src/RenderWindow.h"
#include "Src/FBXImporter.h"
#include <windows.h>

static ANvDbg::RenderWindow* s_render_window = nullptr;

void DrawScene()
{
    s_render_window->RenderOneFrame();
}

void MainLoop(HDC dc)
{
    MSG msg;
    while (true)
    {
        if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
            {
                break;
            }

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        DrawScene();
    }
}

INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
{
    ANvDbg::NTWindow::g_app_instance = hInstance;
    ANvDbg::NTWindow::RegisterNTWindow(L"NTWindow", CS_HREDRAW | CS_VREDRAW);
    s_render_window = ANvDbg::NTWindow::CreateNTWindow<ANvDbg::RenderWindow>(
        L"NTWindow", L"OpenGL Render Window", WS_OVERLAPPEDWINDOW);
    s_render_window->Init();
    s_render_window->ShowNTWindow(true);

    ANvDbg::FBXImporter::Test();

    MainLoop(s_render_window->GetWindowDC());

    return 0;
}
